﻿package cgs.server.logging.messages
{
    import cgs.server.logging.*;

    dynamic public class Message extends Object
    {
        protected var _messageObject:Object;
        protected var _gameServerData:GameServerData;

        public function Message(param1:GameServerData = null)
        {
            this._messageObject = {};
            this._gameServerData = param1 == null ? (GameServerData.instance) : (param1);
            return;
        }// end function

        public function set serverData(param1:GameServerData) : void
        {
            this._gameServerData = param1;
            return;
        }// end function

        public function addProperty(param1:String, param2) : void
        {
            this._messageObject[param1] = param2;
            return;
        }// end function

        public function get messageObject() : Object
        {
            return this._messageObject;
        }// end function

        public function injectSKEY() : void
        {
            var _loc_1:* = this._gameServerData.skeyHashVersion;
            if (_loc_1 == GameServerData.UUID_SKEY_HASH)
            {
                this._messageObject.skey = this._gameServerData.createSkeyHash(GameServerData.uuid);
            }
            else if (_loc_1 == GameServerData.NO_SKEY_HASH)
            {
                this._messageObject.skey = this._gameServerData.skey;
            }
            return;
        }// end function

        public function injectGameParams() : void
        {
            this._messageObject.g_name = this._gameServerData.g_name;
            this._messageObject.gid = this._gameServerData.gid;
            this._messageObject.vid = this._gameServerData.vid;
            if (!this._gameServerData.legacyMode)
            {
                this._messageObject.svid = this._gameServerData.svid;
            }
            return;
        }// end function

        public function injectParams() : void
        {
            this.injectGameParams();
            this._messageObject.uid = this._gameServerData.uuid;
            this._messageObject.cid = this._gameServerData.cid;
            this.injectSKEY();
            return;
        }// end function

        public function injectUserName() : void
        {
            this._messageObject.uname = this._gameServerData.userName;
            return;
        }// end function

        public function injectEventID(param1:Boolean) : void
        {
            if (param1 || this._gameServerData.isEventIDValid)
            {
                this._messageObject.eid = this._gameServerData.isEventIDValid ? (this._gameServerData.eid) : (0);
            }
            return;
        }// end function

        public function injectTypeID(param1:Boolean) : void
        {
            if (param1 || this._gameServerData.isTypeIDValid)
            {
                this._messageObject.tid = this._gameServerData.isTypeIDValid ? (this._gameServerData.tid) : (0);
            }
            return;
        }// end function

        public function injectLevelID(param1:Boolean) : void
        {
            if (param1 || this._gameServerData.isLevelIDValid)
            {
                this._messageObject.lid = this._gameServerData.isLevelIDValid ? (this._gameServerData.lid) : (0);
            }
            return;
        }// end function

        public function injectSessionID(param1:Boolean) : void
        {
            if (param1 || this._gameServerData.isSessionIDValid)
            {
                this._messageObject.sid = this._gameServerData.isSessionIDValid ? (this._gameServerData.sid) : ("0");
            }
            return;
        }// end function

    }
}
